home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIStreamConverter.idl < prev    next >
Text File  |  2006-05-08  |  6KB  |  133 lines

  1. /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #include "nsIStreamListener.idl"
  39. #include "nsIInputStream.idl"
  40. #include "nsIURI.idl"
  41.  
  42. /**
  43.  * nsIStreamConverter provides an interface to implement when you have code
  44.  * that converts data from one type to another.
  45.  *
  46.  * Suppose you had code that converted plain text into HTML. You could implement
  47.  * this interface to allow everyone else to use your conversion logic using a 
  48.  * standard api.
  49.  * <p>
  50.  * <b>STREAM CONVERTER USERS</b>
  51.  *
  52.  * There are currently two ways to use a stream converter:
  53.  * <ol>
  54.  * <li> <b>SYNCHRONOUS</b> Stream to Stream
  55.  *    You can supply the service with a stream of type X
  56.  *    and it will convert it to your desired output type and return
  57.  *    a converted (blocking) stream to you.</li>
  58.  *
  59.  * <li> <b>ASYNCHRONOUS</b> nsIStreamListener to nsIStreamListener
  60.  *    You can supply data directly to the converter by calling it's
  61.  *    nsIStreamListener::OnDataAvailable() method. It will then
  62.  *    convert that data from type X to your desired output type and
  63.  *    return converted data to you via the nsIStreamListener you passed
  64.  *    in by calling its OnDataAvailable() method.</li>
  65.  * </ol>
  66.  * <p>
  67.  *
  68.  * <b>STREAM CONVERTER SUPPLIERS</b>
  69.  *
  70.  * Registering a stream converter:
  71.  * Stream converter registration is a two step process. First of all the stream
  72.  * converter implementation must register itself with the component manager using
  73.  * a contractid in the format below. Second, the stream converter must add the contractid
  74.  * to the registry.
  75.  *
  76.  * Stream converter contractid format (the stream converter root key is defined in this
  77.  * file):
  78.  *
  79.  * <pre>@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPE</pre>
  80.  *
  81.  * @author Jud Valeski
  82.  * @see nsIStreamConverterService
  83.  */
  84.  
  85. [scriptable, uuid(0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b)]
  86. interface nsIStreamConverter : nsIStreamListener {
  87.  
  88.     /**
  89.      * <b>SYNCRONOUS VERSION</b>
  90.      * Converts a stream of one type, to a stream of another type.
  91.      *
  92.      * Use this method when you have a stream you want to convert.
  93.      *
  94.      * @param aFromStream   The stream representing the original/raw data.
  95.      * @param aFromType     The MIME type of aFromStream.
  96.      * @param aToType       The MIME type of the returned stream.
  97.      * @param aCtxt         Either an opaque context, or a converter specific context
  98.      *                      (implementation specific).
  99.      * @return              The converted stream. NOTE: The returned stream may not
  100.      *                      already be converted. An efficient stream converter
  101.      *                      implementation will converter data on demand rather than
  102.      *                      buffering the converted data until it is used.
  103.      */
  104.     nsIInputStream convert(in nsIInputStream aFromStream,
  105.                            in string aFromType,
  106.                            in string aToType,
  107.                            in nsISupports aCtxt);
  108.  
  109.     /**
  110.      * <b>ASYNCRONOUS VERSION</b>
  111.      * Converts data arriving via the converter's nsIStreamListener::OnDataAvailable() 
  112.      * method from one type to another, pushing the converted data out to the caller 
  113.      * via aListener::OnDataAvailable().
  114.      *
  115.      * Use this method when you want to proxy (and convert) nsIStreamListener callbacks
  116.      * asynchronously.
  117.      *
  118.      * @param aFromType     The MIME type of the original/raw data.
  119.      * @param aToType       The MIME type of the converted data.
  120.      * @param aListener     The listener who receives the converted data.
  121.      * @param aCtxt         Either an opaque context, or a converter specific context
  122.      *                      (implementation specific).
  123.      */
  124.     void asyncConvertData(in string aFromType,
  125.                           in string aToType,
  126.                           in nsIStreamListener aListener,
  127.                           in nsISupports aCtxt);
  128. };
  129.  
  130. %{C++
  131. #define NS_ISTREAMCONVERTER_KEY         "@mozilla.org/streamconv;1"
  132. %}
  133.